<?php 
function the_title2($before = '', $after = '', $echo = true, $length = false) {
         $title = get_the_title();

      if ( $length && is_numeric($length) ) {

             $title = substr( $title, 0, $length );

          }

        if ( strlen($title)> 0 ) {

             $title = apply_filters('the_title2', $before . $title . $after, $before, $after);

             if ( $echo )

                echo $title;

             else

                return $title;

          }

      }

?>
<?php
if ( function_exists('register_sidebar') )
    register_sidebar(array(
        'before_widget' => '<div class="sidebar-box">',
    'after_widget' => '</div>',
 'before_title' => '<h3>',
        'after_title' => '</h3>',
    ));
?>
<?php
$themename = "TidalForce Theme";
$shortname = "artsee";
$options = array (
    
    array(    "name" => "Body background color",
            "id" => $shortname."_body_backgroundcolor",
            "std" => "#000000",
            "type" => "text"),
			
	array(    "name" => "Link Color",
            "id" => $shortname."_link_color",
            "std" => "#003078",
            "type" => "text"),
			
	array(    "name" => "Pages Link Color",
            "id" => $shortname."_nav_color",
            "std" => "#FFFFFF",
            "type" => "text"),
			
	array(    "name" => "Categories Link Color",
            "id" => $shortname."_cat_color",
            "std" => "#FFFFFF",
            "type" => "text"),

	array(    "name" => "Sidebar Link Color",
            "id" => $shortname."_side_color",
            "std" => "#FFFFFF",
            "type" => "text"),
			
	array(    "name" => "Sidebar Link Hover Color",
            "id" => $shortname."_side_hover_color",
            "std" => "#CADFFF",
            "type" => "text"),
					
	array(    "name" => "Font Color",
            "id" => $shortname."_font_color",
            "std" => "#000000",
            "type" => "text"),
    
    array(    "name" => "Font Type",
            "id" => $shortname."_body_font",
            "type" => "select",
            "std" => "Verdana",
            "options" => array("Verdana", "Arial", "Georgia")),

	array(    "name" => "H3 Color",
            "id" => $shortname."_h3_color",
            "std" => "#FFFFFF",
            "type" => "text"),
			
    array(    "name" => "Hide/Display Share Button",
            "id" => $shortname."_share",
            "type" => "select",
            "std" => "visible",
            "options" => array("visible", "hidden")),
			
	array(    "name" => "About Us Text",
            "id" => $shortname."_about",
            "std" => "Input your about us text here.",
            "type" => "text2"),
			
	array(    "name" => "Feedburner URL",
            "id" => $shortname."_feed",
            "std" => "Input your feedburner url here",
            "type" => "text"),
			
    array(    "name" => "Number of Posts Displayed on Homepage",
            "id" => $shortname."_homepage_posts",
            "type" => "select",
            "std" => "6",
            "options" => array("2", "4", "6", "8", "10", "12", "14", "16", "18", "20")),
					
);

function mytheme_add_admin() {

    global $themename, $shortname, $options;

    if ( $_GET['page'] == basename(__FILE__) ) {
    
        if ( 'save' == $_REQUEST['action'] ) {

                foreach ($options as $value) {
                    update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }

                foreach ($options as $value) {
                    if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }

                header("Location: themes.php?page=functions.php&saved=true");
                die;

        } else if( 'reset' == $_REQUEST['action'] ) {

            foreach ($options as $value) {
                delete_option( $value['id'] ); }

            header("Location: themes.php?page=functions.php&reset=true");
            die;

        }
    }

    add_theme_page($themename." Options", "Current Theme Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');

}

function mytheme_admin() {

    global $themename, $shortname, $options;

    if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
    if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
    
?>
<div class="wrap">
<h2><?php echo $themename; ?> settings</h2>

<form method="post">

<table class="optiontable">

<?php foreach ($options as $value) { 
    
if ($value['type'] == "text") { ?>
        
<tr valign="top"> 
    <th scope="row"><?php echo $value['name']; ?>:</th>
    <td>
        <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" />
    </td>
</tr>
  
<?php } elseif ($value['type'] == "text2") { ?>
        
<tr valign="top"> 
    <th scope="row"><?php echo $value['name']; ?>:</th>
    <td>
        <textarea name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" style="width: 400px; height: 200px;" type="<?php echo $value['type']; ?>"><?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?></textarea>
    </td>
</tr>

<?php } elseif ($value['type'] == "select") { ?>

    <tr valign="top"> 
        <th scope="row"><?php echo $value['name']; ?>:</th>
        <td>
            <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
                <?php foreach ($value['options'] as $option) { ?>
                <option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option>
                <?php } ?>
            </select>
        </td>
    </tr>

<?php 
} 
}
?>

</table>

<p class="submit">
<input name="save" type="submit" value="Save changes" />    
<input type="hidden" name="action" value="save" />
</p>
</form>
<form method="post">
<p class="submit">
<input name="reset" type="submit" value="Reset" />
<input type="hidden" name="action" value="reset" />
</p>
</form>

<?php
}

function mytheme_wp_head() { ?>
<link href="<?php bloginfo('template_directory'); ?>/style.php" rel="stylesheet" type="text/css" />
<?php }

add_action('wp_head', 'mytheme_wp_head');
add_action('admin_menu', 'mytheme_add_admin'); ?>
<?php
/*
Plugin Name: Most Commented
Plugin URI: http://mtdewvirus.com/code/wordpress-plugins/
Description: Retrieves a list of the posts with the most comments. Modified for Last X days -- by DJ Chuang www.djchuang.com 
Version: 1.5
Author: Nick Momrik
Author URI: http://mtdewvirus.com/
*/

function mdv_most_commented($no_posts = 7, $before = '<li>', $after = '</li>', $show_pass_post = false, $duration='') {
    global $wpdb;
	
	$mdv_most_commented = wp_cache_get('mdv_most_commented');
	if ($mdv_most_commented === false) {
		$request = "SELECT ID, post_title, comment_count FROM $wpdb->posts";
		$request .= " WHERE post_status = 'publish'";
		if (!$show_pass_post) $request .= " AND post_password =''";
	
		if ($duration !="") $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
	
		$request .= " ORDER BY comment_count DESC LIMIT $no_posts";
		$posts = $wpdb->get_results($request);

		if ($posts) {
			foreach ($posts as $post) {
				$post_title = stripslashes($post->post_title);
				$comment_count = $post->comment_count;
				$permalink = get_permalink($post->ID);
				$mdv_most_commented .= $before . '<a href="' . $permalink . '" title="' . $post_title.'">' . $post_title . '</a> (' . $comment_count.')' . $after;
			}
		} else {
			$mdv_most_commented .= $before . "None found" . $after;
		}
	
		wp_cache_set('mdv_most_commented', $mdv_most_commented);
	} 

    echo $mdv_most_commented;
}
?>